﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EFB.Lib.Entity;
using EFB.Lib.Process;

namespace EFB.Web {

    public partial class Default : BasePage {

        protected void Page_Load(object sender, EventArgs e) {

        }

        protected void LoginButton_Command(object sender, CommandEventArgs e) {
            BaseProcess Process = new BaseProcess();
            try {
                if (e.CommandName.Equals("Acessar", StringComparison.InvariantCultureIgnoreCase)) {
                    Process.DatabaseConnect();
                    UsuarioEntity Usuario = new UsuarioEntity();
                    Usuario.Login = LoginField.Text;
                    Usuario.Senha = PasswordField.Text;
                    UsuarioProcess UsuarioPrc = new UsuarioProcess();
                    UsuarioPrc.Acessar(ref Usuario);
                    base.SessionUser = Usuario;
                    Response.Redirect("~/Home.aspx", true);
                }
            } catch (Exception Except) {
                FailureText.Text = base.FormatExceptionText(Except);
                FailureText.Visible = true;
                FailureContainer.Visible = true;
            } finally {
                Process.DatabaseDisconnect();
            }
        }

    }

}